package base.io;

import java.io.*;

/**
 * 处理流
 */
public class BufferedInputAndOutputStream {
  
  private static String COMMON_PATH = "E:%stest%s";
  
  public static void main(String[] args) throws IOException {
    File inputFile = new File(String.format(COMMON_PATH + "111.input.jpg", File.separator, File.separator));
    File outputFile = new File(String.format(COMMON_PATH + "111.output.jpg", File.separator, File.separator));
    
    FileInputStream fileInputStream = new FileInputStream(inputFile);
    FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
    
    // 这里是一个 缓冲流
    BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
    BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
    
    byte[] bytes = new byte[1024 * 10];
    int readLength;
    while ((readLength = bufferedInputStream.read(bytes)) != -1)
      bufferedOutputStream.write(bytes, 0, readLength);
    
    bufferedInputStream.close();
    bufferedOutputStream.close();
  }
}
